//package com.example.config;
//
//import com.alibaba.nacos.api.utils.StringUtils;
//import org.reactivestreams.Publisher;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.cloud.gateway.filter.GatewayFilterChain;
//import org.springframework.cloud.gateway.filter.GlobalFilter;
//import org.springframework.cloud.gateway.filter.NettyWriteResponseFilter;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.Ordered;
//import org.springframework.core.io.buffer.DataBuffer;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.server.reactive.ServerHttpRequest;
//import org.springframework.http.server.reactive.ServerHttpResponse;
//import org.springframework.http.server.reactive.ServerHttpResponseDecorator;
//import org.springframework.web.server.ServerWebExchange;
//import reactor.core.publisher.Mono;
//
//@Configuration
//public class ResponseGlobalFilter implements GlobalFilter, Ordered {
//
// private String crossOriginPath="http://localhost:8083";
//
//
// @Override
// public Mono<Void> filter(ServerWebExchange exchange,
//                          GatewayFilterChain chain) {
//  String path = exchange.getRequest().getPath().value();
//  if(path.contains("/oauth/authorize") || path.contains("/auth/authorize")){
//   //构建响应包装类
//   HttpResponseDecorator responseDecorator = new HttpResponseDecorator(exchange.getRequest(),exchange.getResponse(), crossOriginPath);
//   return chain
//    .filter(exchange.mutate().response(responseDecorator).build());
//  }
//  return chain.filter(exchange);
// }
//
// @Override
// public int getOrder() {
//  //WRITE_RESPONSE_FILTER 之前执行
//  return NettyWriteResponseFilter.WRITE_RESPONSE_FILTER_ORDER - 1;
// }
//
//}
//
